home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Unix / CNews / Source / h / news.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-27  |  5.0 KB  |  148 lines

  1. /*
  2.  * definitions unique to all of C news
  3.  * things marked with qqq are subject to being configured by "build"
  4.  */
  5.  
  6. /*
  7.  * tunable parameters
  8.  * which actually very seldom need to be tuned
  9.  * in particular, don't get alarmed about MAXCOMP, it's not used for
  10.  *  anything where it matters
  11.  */
  12. #define MAXPATH 1024        /* max. length of pwd output */
  13. #define MAXCOMP 14        /* file name component length */
  14. #define MAXHOST 128        /* max. length of this host's name */
  15. #define SPOOLTMP ".tmpXXXXXX"    /* template for NEWSARTS temporary link */
  16.  
  17.  
  18. /* STATIC & FORWARD must agree to avoid redeclarations(!) */
  19. #ifndef STATIC
  20. #define STATIC    static        /* "static" when not debugging|profiling */
  21. #endif
  22.  
  23. /* adapt to compiler limitations */
  24. #ifndef FORWARD
  25. #ifdef pdp11
  26. #define FORWARD            /* "static" except for dmr's 11 compiler */
  27. #else
  28. #define FORWARD static        /* "static" except for dmr's 11 compiler */
  29. #endif
  30. #endif
  31. #ifdef NOVOID
  32. #define void int        /* if your compiler doesn't understand void's */
  33. #endif
  34. #ifdef NOUNSLONG
  35. #define MAXLONG 017777777777L    /* if your compiler lacks "unsigned long" type */
  36. #endif
  37.  
  38. /* fundamental constants of the implementation */
  39. #define SMALLMEM    /* qqq for PDP-11s, PDP-8s, IBM PCs, etc. */
  40. #define    FASTSTRCHR    /* qqq if string functions are very fast */
  41.  
  42. /* automatic configuration */
  43. #ifdef pdp11
  44. #ifndef SMALLMEM
  45. #define SMALLMEM
  46. #endif                /* SMALLMEM */
  47. #endif                /* pdp11 */
  48.  
  49.  
  50. /* types */
  51. typedef short statust;
  52. typedef char boolean;
  53.  
  54. /* status bits */
  55. #define ST_OKAY        0    /* nothing wrong */
  56. #define ST_SHORT    (1<<1)    /* article shorter than byte count; truncated? */
  57. #define ST_ACCESS    (1<<2)    /* no access permission */
  58. #define ST_REFUSED    (1<<3)    /* article was deliberately refused - OK */
  59. #define ST_DROPPED    (1<<4)    /* article was accidentally dropped */
  60. #define ST_DISKFULL    (1<<5)    /* disk full - give up */
  61. #define ST_JUNKED    (1<<6)    /* article was accepted, but junked */
  62. #define ST_NEEDATTN    (1<<7)    /* news system needs human attention - give up */
  63.  
  64. /* newsgroup specific definitions */
  65. #define NGSEP ','        /* separates groups */
  66. #define NGNEG '!'        /* preceding a pattern, negates it */
  67. #define NGDELIM '.'        /* within a group */
  68. #define SNGDELIM "."        /* string of NGDELIM */
  69. #define FNDELIM '/'        /* within a group, on disk */
  70. #define SFNDELIM "/"        /* string of FNDELIM */
  71.  
  72. /* macros, replacing functions for speed */
  73. #define max(a,b) ((a) > (b)? (a): (b))
  74. #define min(a,b) ((a) < (b)? (a): (b))
  75. #define iswhite(c) ((c) == ' ' || (c) == '\t')
  76. /* STREQ is an optimised strcmp(a,b)==0 */
  77. #define STREQ(a, b) ((a)[0] == (b)[0] && strcmp(a, b) == 0)
  78. /* STREQN is an optimised strncmp(a,b,n)==0; assumes n > 0 */
  79. #define STREQN(a, b, n) ((a)[0] == (b)[0] && strncmp(a, b, n) == 0)
  80. #define STRLEN(s) ((unsigned)sizeof(s) - 1)    /* s must be a char array */
  81. #ifdef FASTSTRCHR
  82. #define STRCHR(src, chr, dest) (dest) = strchr(src, chr)
  83. #else
  84. #define STRCHR(src, chr, dest) \
  85.     for ((dest) = (src); *(dest) != '\0' && *(dest) != (chr); ++(dest)) \
  86.         ; \
  87.     if (*(dest) == '\0') \
  88.         (dest) = NULL        /* N.B.: missing semi-colon */
  89. #endif
  90.  
  91. /* macros, of necessity */
  92. /* nnafree(any **) where "any" is any type; must be a macro */
  93. #define nnafree(mempp) (*(mempp) != 0? (free((char *)*(mempp)), (*(mempp) = 0)): 0)
  94. #ifdef lint
  95. static
  96. nnfree(mempp)        /* If *mempp is non-null, free it and zero it. */
  97. register char **mempp;            /* pointer to malloc'ed ptr. */
  98. {
  99.     if (*mempp != 0) {
  100.         free(*mempp);
  101.         *mempp = 0;
  102.     }
  103. }
  104. #else                    /* lint */
  105. #define nnfree nnafree
  106. #endif                    /* lint */
  107.  
  108. #define YES 1
  109. #define NO 0
  110.  
  111. #define SIZENUL (sizeof(char))        /* size in bytes of an ASCII NUL byte */
  112.  
  113. #define NOTALLHDRS NO            /* hdrdump flags for "all headers seen?" */
  114. #define ALLHDRS YES
  115.  
  116. #define DEFEXP "-"            /* default expiry period */
  117.  
  118. /* imports from news */
  119. extern char *progname;
  120.  
  121. extern void fclsexec();                /* from ../libos */
  122. extern FILE *fopenexcl();            /* from ../libos */
  123. extern char *getcwd();                /* from ../libos */
  124.  
  125. extern FILE *fopenclex(), *fopenwclex();    /* from ../libcnews/fopenclex.c */
  126. extern char *gethdr();                /* from ../libcnews/gethdr.c */
  127. extern char *hostname();            /* from ../libcnews/hostname.c */
  128. extern void lockdebug(), newslock(), newsunlock();    /* from ../libcnews/lock.c */
  129. extern void errunlock();            /* from ../libcnews/lock.c */
  130. extern int ltozan(), ltoza();            /* from ../libcnews/ltoza.c */
  131. extern void matchdebug();            /* from ../libcnews/ngmatch.c */
  132. extern boolean ngmatch();            /* from ../libcnews/ngmatch.c */
  133. extern void mkfilenm();                /* from ../libcnews/string.c */
  134. extern char *trim();                /* from ../libcnews/string.c */
  135. extern boolean anyhostin(), hostin();        /* from ../libcnews/string.c */
  136. extern int hopcount();                /* from ../libcnews/string.c */
  137. extern char *skipsp(), *first(), *strsvto();    /* from ../libcnews/string.c */
  138. extern char *sendersite(), *nullify();        /* from ../libcnews/string.c */
  139. extern char *canonpath();            /* from ../libcnews/string.c */
  140. extern void timestamp();            /* from ../libcnews/time.c */
  141.  
  142. extern void warning(), error();            /* from ../libc */
  143. extern void closeall();                /* from ../libc */
  144. extern void stdfdopen();            /* from ../libc */
  145. extern int nfclose();                /* from ../libc */
  146.  
  147. #include "alloc.h"                /* ugh */
  148.